 <?php

    /*
     * curl
     */
     function http_curl($url,$data =array(),$method ="get",$returnType ="json")
    {
        //1.开启会话
        $ch = curl_init();
        //2.设置参数

        curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE);
        curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
        if($method!="get"){
            curl_setopt($ch,CURLOPT_POST,TRUE);
            curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
        }
        curl_setopt($ch,CURLOPT_URL,$url);
        //执行会话
        $json = curl_exec($ch);
        curl_close($ch);
        if($returnType == "json"){
            return json_decode($json,true);
        }
        return $json;
    }